Book Contents

Right Shift operator ( >> )

Shifts the bits within the left operand by the amount specified in the right operand. The bit on the right disappears.

Either a 0 or a 1 is shifted in on the left, depending on whether the integer is signed or unsigned. With unsigned integers, 0 is always shifted in on the left; with signed integers, a 0 is shifted in when the number is positive (i.e., the leftmost bit, the sign bit, is 0), and a 1 is shifted in when the number is negative (i.e., the leftmost bit, the sign bit, is 1). In other words, with signed integers, the sign of the number is always maintained.

See also

Quick reference to operators